package com.ssy.lingxi.report.controller;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.report.model.vo.response.*;
import com.ssy.lingxi.report.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @menu 平台后台-平台后台首页
 * @author 伍将
 * @version 2.0.0
 * @date 2020/11/0
 */
@RestController
@RequestMapping("/report/platform/home")
public class PlatformHomeController extends BaseController {

    @Autowired
    private IMemberReportService memberReportService;

    @Autowired
    private IOrderReportService orderReportService;

    @Autowired
    private INewlyAddedDayReportService newlyAddedDayReportService;

    @Autowired
    private IPlatformHomeService platformHomeService;
    @Autowired
    private IContractReportService contractReportServiceService;

    /***
     * 获取会员统计
     * @author 伍将
     * @date 2020/11/10
     **/
    @RequestMapping(value = "/getMemberRegisterList", method = RequestMethod.GET)
    Wrapper<MemberRegisterStatisticsVO> getMemberRegisterList(HttpServletRequest httpRequest) {
        return memberReportService.getMemberRegisterList(getSysUser(httpRequest));
    }

    /***
     * 获取订单统计[销售订单统计]
     * @author 伍将
     * @date 2020/11/10
     **/
    @RequestMapping(value = "/getOrderList", method = RequestMethod.GET)
    Wrapper<OrderStatisticsVO> getOrderList(HttpServletRequest httpRequest) {
        return orderReportService.getOrderList(getSysUser(httpRequest));
    }

    /***
     * 获取采购统计[实际统计合同数据]
     * @author ds
     * @date 2021/6/10
     **/
    @RequestMapping(value = "/getPurchaseList", method = RequestMethod.GET)
    Wrapper<PurchaseStatisticsVO> getPurchaseList(HttpServletRequest httpRequest) {
        return contractReportServiceService.getPurchaseList(getSysUser(httpRequest));
    }

    /**
     *  获取采购计数
     * @author ds
     * @date 2021/6/15
     * @version 2.0.0
     */
    @RequestMapping(value = "/getPurchaseTally", method = RequestMethod.GET)
    Wrapper<PurchaseTallyVO> getPurchaseTally(HttpServletRequest httpRequest) {
        return platformHomeService.getPurchaseTally(getSysUser(httpRequest));
    }

    /**
     * 获取今日新增报表
     * @author 伍将
     * @date 2020/11/12
     **/
    @RequestMapping(value = "/getNewlyAddedDayReport", method = RequestMethod.GET)
    Wrapper<NewlyAddedDayReportVO> getNewlyAddedDayReport(HttpServletRequest httpRequest) {
        return newlyAddedDayReportService.getNewlyAddedDayReport(getSysUser(httpRequest));
    }

    /**
     * 获取会员计数报表
     * @author 伍将
     * @date 2020/11/24
     **/
    @RequestMapping(value = "/getMemberTally", method = RequestMethod.GET)
    Wrapper<List<TallyReportItemVO>> getMemberTally(HttpServletRequest httpRequest) {
        return platformHomeService.getMemberTally(getSysUser(httpRequest));
    }

    /**
     * 获取交易与售后计数报表
     * @author 伍将
     * @date 2020/11/24
     **/
    @RequestMapping(value = "/getTradeAndAfterSaleTally", method = RequestMethod.GET)
    Wrapper<TradeAndAfterSaleTallyVO> getTradeAndAfterSaleTally(HttpServletRequest httpRequest) {
        return platformHomeService.getTradeAndAfterSaleTally(getSysUser(httpRequest));
    }

    /**
     * 获取商品计数报表
     * @author 伍将
     * @date 2020/11/24
     **/
    @RequestMapping(value = "/getCommodityTally", method = RequestMethod.GET)
    Wrapper<PlatformCommodityTallyVO> getCommodityTally(HttpServletRequest httpRequest) {
        return platformHomeService.getCommodityTally(getSysUser(httpRequest));
    }

    /**
     * 获取资金与结算中心计数报表
     * @author 伍将
     * @date 2020/11/24
     **/
    @RequestMapping(value = "/getAccountAndSettleAccountTally", method = RequestMethod.GET)
    Wrapper<AccountAndSettleAccountTallyVO> getAccountAndSettleAccountTally(HttpServletRequest httpRequest) {
        return platformHomeService.getAccountAndSettleAccountTally(getSysUser(httpRequest));
    }
}
